home *** CD-ROM | disk | FTP | other *** search
- property saveList, saveUrllist, urlList, memberName
- global world, vitualObj, CD
-
- on new me, aList
- me.memberName = "urlParent"
- put EMPTY into field "urlList"
- saveList = [#urlList]
- saveUrllist = [#urlList]
- urlList = []
- if listp(aList) then
- tempL = getaProp(aList, #urlList)
- repeat with x = 1 to count(tempL)
- aList = getAt(tempL, x)
- aName = getaProp(aList, #name)
- add(urlList, new(script(aName), aList, 0))
- end repeat
- else
- end if
- loadLocal(me)
- return me
- end
-
- on loadLocal me
- if CD = 1 then
- tell the stage
- readText("itchLink")
- end tell
- itchLink = value(the result)
- else
- if voidp(getPref("itchLink")) then
- SetPref("itchLink", string([:]))
- end if
- itchLink = value(getPref("itchLink"))
- end if
- repeat with x = 1 to count(itchLink)
- p = getPropAt(itchLink, x)
- obj = getObjfromUID(me, p)
- if objectp(obj) then
- aList = getAt(itchLink, x)
- if listp(aList) then
- put getaProp(aList, #version) && obj.version
- if voidp(getaProp(aList, #played)) then
- next repeat
- end if
- if getaProp(aList, #version) = obj.version then
- obj.played = getaProp(aList, #played)
- end if
- end if
- end if
- end repeat
- end
-
- on saveLocal me
- temp = [:]
- repeat with x in urlList
- if x.played then
- addProp(temp, x.uniqueID, [#played: x.played, #version: x.version])
- end if
- end repeat
- if CD = 1 then
- tell the stage
- saveText("itchLink", string(temp))
- end tell
- else
- SetPref("itchLink", string(temp))
- end if
- end
-
- on getIDfromLine me, num
- if count(urlList) < num then
- return 0
- end if
- temp = getAt(urlList, num)
- if not objectp(temp) then
- return 0
- end if
- return temp.uniqueID
- end
-
- on getNameFromUID me, link
- obj = getObjfromUID(me, link)
- if obj = 0 then
- return 0
- end if
- temp = obj.fileNam
- if temp = 0 then
- return 0
- end if
- return temp
- end
-
- on deteteUrl me, path
- temp = getObjFromPath(me, path)
- if temp = 0 then
- return 0
- end if
- deleteURL(world, temp.uniqueID)
- deleteOne(urlList, temp)
- return 1
- end
-
- on getObjFromPath me, path
- repeat with x in urlList
- if x.originalpath = path then
- return x
- end if
- end repeat
- return 0
- end
-
- on getObjfromUID me, link
- repeat with x in urlList
- if x.uniqueID = link then
- return x
- end if
- end repeat
- return 0
- end
-
- on getPropfromUID me, link, aprop
- repeat with x in urlList
- if x.uniqueID = link then
- return getaProp(x, aprop)
- end if
- end repeat
- return 0
- end
-
- on search me
- fileObj = new(xtra("fileio"))
- answer = displayOpen(fileObj)
- if answer = EMPTY then
- return
- end if
- delete char 1 to the number of chars in the moviePath of answer
- if checkDuplicate(me, answer) then
- alert("duplicate")
- return
- end if
- fileObj = 0
- end
-
- on checkDuplicate me, answer
- repeat with x in urlList
- if x.originalpath = answer then
- return 1
- end if
- end repeat
- addURL(me, answer)
- return 0
- end
-
- on addURL me, apath
- add(urlList, new(script("linkParent"), 0, apath))
- end
-
- on getURLList me
- temp = EMPTY
- repeat with x = 1 to count(urlList)
- obj = getAt(urlList, x)
- put obj.originalpath into line x of temp
- end repeat
- return temp
- end
-